function countBits(num) {
  let result = [0]
  let n = 1
  while (n <= num) {
    let count = 0
    let tempN = n
    while (tempN !== 0) {
      count++
      tempN &= (tempN - 1)
    }
    result.push(count)
    n++
  }
  return result
}